package es.uc3m.setichat.mensaje;


import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class HeaderMessage {


    private String idSource;

    private String idDestination;

    private String idMessage;

    private String type;

    private boolean encrypted;

    private boolean signed;

    public HeaderMessage (Document doc){
        NodeList idSource = doc.getElementsByTagName("header");
        Node idSourceContenido =idSource.item(0);
        Element idSourceElement = (Element) idSourceContenido;
        setIdSource(idSourceElement.getElementsByTagName("idSource").item(0).getTextContent());
        setIdDestination(idSourceElement.getElementsByTagName("idDestination").item(0).getTextContent());
        setIdMessage(idSourceElement.getElementsByTagName("idMessage").item(0).getTextContent());
        setType(idSourceElement.getElementsByTagName("type").item(0).getTextContent());
        setEncrypted(Boolean.valueOf(idSourceElement.getElementsByTagName("encrypted").item(0).getTextContent()));
        setSigned(Boolean.valueOf(idSourceElement.getElementsByTagName("signed").item(0).getTextContent()));
//        Element idSourceElemento = (Element) idSourceContenido;
//        idSourceElemento.getElementsByTagName()


    }

    public String getIdDestination() {
        return idDestination;
    }

    public void setIdDestination(String idDestination) {
        this.idDestination = idDestination;
    }

    public String getIdMessage() {
        return idMessage;
    }

    public void setIdMessage(String idMessage) {
        this.idMessage = idMessage;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public boolean isEncrypted() {
        return encrypted;
    }

    public void setEncrypted(boolean encrypted) {
        this.encrypted = encrypted;
    }

    public boolean isSigned() {
        return signed;
    }

    public void setSigned(boolean signed) {
        this.signed = signed;
    }

    public void setIdSource(String idSource){
        this.idSource= idSource;
    }
    public String getIdSource(){
        return idSource;
    }

}